master
 1---
 2import { asideConfig, commentConfig, siteConfig } from '@/config';
 3import ProfileCard from '@components/aside/ProfileCard.astro';
 4import RecentCommentsCard from '@components/aside/RecentCommentsCard.tsx';
 5import SiteInfoCard from '@components/aside/SiteInfoCard.astro';
 6import CategoryBar from '@components/misc/CategoryBar.astro';
 7import PostsPage from '@components/PostsPage.astro';
 8import MainLayout from '@layouts/MainLayout.astro';
 9import { getCategories, getSortedPosts } from '@utils/content-utils';
10
11export async function getStaticPaths() {
12  const articles = await getSortedPosts();
13  const pageNum = Math.ceil(articles.length / siteConfig.postsPerPage);
14  let pages = Array.from({ length: pageNum }).map((_, i) => ({
15    params: { page: i + 1 === 1 ? undefined : 'page/' + (i + 1).toString() },
16    props: { page: i + 1 },
17  }));
18  return pages;
19}
20
21const { page } = Astro.props;
22const articles = await getSortedPosts();
23const categories = await getCategories();
24---
25
26<MainLayout>
27  <CategoryBar categories={Array.from(categories.keys())} />
28  <PostsPage
29    posts={articles}
30    currentPage={page}
31    baseUrl={`/page`}
32    specialPage={[{ page: 1, url: '/' }]}
33  />
34  <Fragment slot="aside-fixed">
35    <ProfileCard />
36    <SiteInfoCard />
37  </Fragment>
38  <Fragment slot="aside-sticky">
39    {
40      commentConfig.enable && asideConfig.recentComment.enable && (
41        <RecentCommentsCard client:visible />
42      )
43    }
44  </Fragment>
45</MainLayout>